<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <li>{{firstName}}+{{lastName}}={{fullName}}</li>
</div>
</body>
<script src="vue.js"></script>
<script>
    var vm = new Vue({
        el:'#app',
        data:{
            firstName:'zhang',
            lastName:'san'
        },
        computed:{
            fullName:{
                get:function () {
                    return this.firstName +  ' ' + this.lastName;
                },
                set:function (val) {
                    //zhang si
                    var arr = val.split(' ');
                    this.firstName = arr[0];
                    this.lastName = arr[1];
                },
                 /*methods:{
                  fullName(){
                      return this.firstName +' '+this.lastName;
                  }*/
    }
            }
    });
    vm.$watch('firstName',function (val,oldVal) {
        console.log(val + "......" +oldVal);
        if (oldVal == 'zhang'){
            this.firstName = oldVal;
        }
    })
</script>
</html>

<!--计算属性具有计算缓存功能：-->